SHELL=cmd.exe
targetDir=$(subst \,/,$(CURDIR))/Debug
target=$(targetDir)/main.exe

src=main.c heap_4.c \
	list.c \
	port.c \
	queue.c \
	tasks.c \
	timers.c \
	event_groups.c \
	supporting_functions.c

objdir=$(subst \,/,$(CURDIR))/objs
objfiles=$(addprefix $(objdir)/,$(src:%.c=%.o))

$(target):$(objfiles)
	@if not exist $(subst /,\,$(targetDir)) (mkdir $(subst /,\,$(targetDir)))
	@gcc -o $(target) $(objfiles) -LD:/mingw/lib -lwinmm
# pattern rules
$(objdir)/%.o:%.c
	@if not exist $(subst /,\,$(objdir)) (mkdir $(subst /,\,$(objdir)))
	@gcc -I./include -c $< -o $@

.PHONY:clean run
clean:
	@-del $(subst /,\,$(objfiles)) $(subst /,\,$(target))
run:
	@call $(subst /,\,$(target))
